<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>供货商配费月报表</title>
</head>
<body>
    <div ng-app="SupplierSalaryApp" ng-controller="SupplierSalaryCtrl">
        <div class="row">
            <ui-container url="report/suppliersalary/list" key="report-suppliersalary-list-00">
                <ui-search-form>
                    <search-select-remote placeholder="请选择商户" url="system/supplier/listall" class="col-md-2" name="supplierCode" value-name="code" text-name="name">
                    </search-select-remote>

                </ui-search-form>
                <ui-table-tool>
                    <a  class="btn btn-sm btn-primary" ng-click="exportDatas()" target="_blank" >导出</a>
                </ui-table-tool>
                <ui-table>

                </ui-table>
                <table-page/>
            </ui-container>
        </div>
    </div>
<script>
    angular.module('SupplierSalaryApp',['ui.table']);
    angular.module('SupplierSalaryApp').controller('SupplierSalaryCtrl', function($scope){
        $scope.exportDatas=function(){
            var uiContainerCtrl=$scope['report-suppliersalary-list-00'];
            //如果下面的表格没有数据（可能是没有搜索可能是没有结果）就判断不能导出
            var tableData=uiContainerCtrl._dataList;
            if (!tableData || tableData.length <= 0) {
                toastr.error('表格数据为空，不能导出');
                return;
            }
            var paramData=uiContainerCtrl._getFormParams();


            var params = {
                url: 'report/suppliersalary/export',
                type: "POST"
            };
            var exportForm = $("<form>");
            for (let i in paramData) {
                if(paramData[i]!=undefined&&paramData[i]!=null&&paramData[i]!=''){
                    $("<input type='hidden' name='" + i + "' value='" + paramData[i] + "'/>").appendTo(exportForm);
                }
            }
            $(exportForm).css("display", "none");
            $(exportForm).attr('target', 'targetFrame');
            $(exportForm).attr('method', params.type);
            $(exportForm).attr('action', params.url);
            exportForm = exportForm.appendTo($("body"));
            exportForm.submit();
            exportForm.remove();
        }
        //每一列的操作按钮
        $scope._columns=[
            {name:'supplierCode',head:'供货商编号'},
            {name:'supplierName',head:'供货商名称'},
            {name:'month',head:'月份'},
            {name:'majorSum',head:'首件单量'},
            {name:'minorSum',head:'拖件单量'},
            {name:'majorFee',head:'首件配费'},
            {name:'minorFee',head:'拖件配费'},
            {name:'totalFee',head:'总配费'}
        ];
    });
</script>
</body>
</html>
